<?php
include("include/config.inc.php");

$pageName = 'outGoingList';
if($_SESSION['s_userType'] == 'User')
{
   $authorization = "NoAccess";
   foreach($selUsermenuArr as $value)
   {
     if(in_array($pageName, $value))
       {
         $authorization ="Access";
         break;
       }
       else 
       {
        $authorization = "NoAccess";    
       }
   }
   if($authorization == "NoAccess")
   {
     header("location:index.php");
   }
}
if(!isset($_SESSION['s_activId']))
{
  $_SESSION['s_urlRedirectDir'] = $_SERVER['REQUEST_URI'];
  header("Location:checkLogin.php");
}
else
{
	$incomingRegister = array();
	$i =0;
 	$selectincomingRegister = "SELECT outgoingMasterId,outgoingmaster.incomingId,outChallenNo,partyName,
	                                  DATE_FORMAT(outgoingmaster.date,'%d-%m-%Y')AS date,incomingQuantity,challan,incomingWeight,
	                                  processName1.processName AS processName1,processName2.processName AS processName2,
	                                  processName3.processName AS processName3,materialName,hardne,dispatchQuantity,dispatchWeight
	                             FROM outgoingmaster
	                             LEFT JOIN incoming ON outgoingmaster.incomingId = incoming.incomingId
	                             LEFT JOIN party ON party.partyId = incoming.partyId
	                             LEFT JOIN process AS processName1 ON processName1.processId = incoming.processId1
	                             LEFT JOIN process AS processName2 ON processName2.processId = incoming.processId2
	                             LEFT JOIN process AS processName3 ON processName3.processId = incoming.processId3
	                             LEFT JOIN material ON material.materialId = incoming.materialId
	                            WHERE (outQuantity > '0' OR outWeight > '0')
	                              AND billGenerated = '0'
	                            ORDER BY outChallenNo	DESC";
	$selectincomingRegisterRes = mysql_query($selectincomingRegister);
	while($incomingRow = mysql_fetch_array($selectincomingRegisterRes))
	{
		$incomingRegister[$i]['outgoingMasterId'] = $incomingRow['outgoingMasterId'];
		$incomingRegister[$i]['incomingId']   = $incomingRow['incomingId'];
		$incomingRegister[$i]['outChallenNo'] = $incomingRow['outChallenNo'];
		$incomingRegister[$i]['partyName']    = $incomingRow['partyName'];
		$incomingRegister[$i]['date']         = $incomingRow['date'];
		$incomingRegister[$i]['qty']          = $incomingRow['incomingQuantity'];
		$incomingRegister[$i]['challan']      = $incomingRow['challan'];
		$incomingRegister[$i]['weight']       = $incomingRow['incomingWeight'];
		$incomingRegister[$i]['processName1'] = $incomingRow['processName1'];
		$incomingRegister[$i]['processName2'] = $incomingRow['processName2'];
		$incomingRegister[$i]['processName3'] = $incomingRow['processName3'];
		$incomingRegister[$i]['material']     = $incomingRow['materialName'];
		$incomingRegister[$i]['hardne']       = $incomingRow['hardne'];
		$incomingRegister[$i]['outQuantity']  = $incomingRow['dispatchQuantity'];
		$incomingRegister[$i]['outWeight']    = $incomingRow['dispatchWeight'];
		$i++;
	}

  include("./bottom.php");
  $smarty->assign("msg",'<font size="6">No Record Found</font>');
	$smarty->assign("incomingRegister",$incomingRegister);
	$smarty->display("outGoingList.tpl");
}
?>